<?php

/**
 * db adapter setting form
 *
 * @author     Mon Zafra <monzee at gmail>
 * @copyright  (c)2009 Mon Zafra
 * @category   Mz
 * @package    modules
 * @subpackage crud
 * @license    http://mz-project.googlecode.com/svn/trunk/LICENSE    MIT License
 * @version    SVN: $Id: DbAdapter.php 15 2009-03-04 11:00:01Z monzee $
 */
class Crud_Form_DbAdapter extends Zend_Form
{
    public function init()
    {
        $decors = array(
            array('ViewHelper', array('separator' => '')),
            array('Label', array('separator' => '')),
            array('Errors', array('separator' => '')),
        );

        $adapters = array(
            'Pdo_Sqlite' => 'PDO - SQLite',
            'Pdo_Mysql' => 'PDO - MySQL',
            'Pdo_Pgsql' => 'PDO - PostgreSQL',
            'Pdo_Mssql' => 'PDO - MS SQL',
            'Pdo_Ibm' => 'PDO - IBM DB2/IDS',
            'Pdo_Oci' => 'PDO - Oracle',
            'Mysqli' => 'MySQLi',
            'Db2' => 'IBM DB2',
            'Oracle' => 'Oracle',
        );

        $this->setAttrib('class', 'mz-dl-form')

            ->addElement('select', 'adapter', array(
                'label' => 'Adapter',
                'decorators' => $decors,
                'multiOptions' => $adapters,
            ))

            ->addElement('text', 'dbname', array(
                'class' => 'text',
                'label' => 'Database name',
                'required' => true,
                'decorators' => $decors,
            ))

            ->addElement('text', 'username', array(
                'class' => 'text',
                'label' => 'Username',
                'decorators' => $decors,
            ))

            ->addElement('password', 'password', array(
                'class' => 'text',
                'label' => 'Password',
                'decorators' => $decors,
            ))

            ->addElement('text', 'host', array(
                'class' => 'text',
                'label' => 'Host',
                'value' => 'localhost',
                'decorators' => $decors,
            ))

            ->addElement('text', 'port', array(
                'class' => 'text',
                'label' => 'Port',
                'decorators' => $decors,
            ))

            ->addElement('submit', 'useConfig', array(
                'class' => 'button',
                'label' => 'Use module config.ini',
                'ignore' => true,
                'decorators' => $decors,
            ))

            ->addElement('submit', 'useDefault', array(
                'class' => 'button',
                'label' => 'Use default ZDT adapter',
                'ignore' => true,
                'decorators' => $decors,
            ))

            ->addElement('submit', 'submit', array(
                'class' => 'button',
                'label' => 'Use custom settings',
                'ignore' => true,
                'decorators' => $decors,
            ))
        ;
    }

}
